import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ApartmentVO, ApartmentForm, ApartmentQuery } from '@/api/apartment/apartment/types';

/**
 * 查询公寓管理列表
 * @param query
 * @returns {*}
 */

export const listApartment = (query?: ApartmentQuery): AxiosPromise<ApartmentVO[]> => {
  return request({
    url: '/apartment/apartment/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询公寓管理详细
 * @param id
 */
export const getApartment = (id: string | number): AxiosPromise<ApartmentVO> => {
  return request({
    url: '/apartment/apartment/' + id,
    method: 'get'
  });
};

/**
 * 新增公寓管理
 * @param data
 */
export const addApartment = (data: ApartmentForm) => {
  return request({
    url: '/apartment/apartment',
    method: 'post',
    data: data
  });
};

/**
 * 修改公寓管理
 * @param data
 */
export const updateApartment = (data: ApartmentForm) => {
  return request({
    url: '/apartment/apartment',
    method: 'put',
    data: data
  });
};

/**
 * 删除公寓管理
 * @param id
 */
export const delApartment = (id: string | number | Array<string | number>) => {
  return request({
    url: '/apartment/apartment/' + id,
    method: 'delete'
  });
};

/**
 * 恢复公寓
 * @param id
 */
export const recoverApartment= (id: string | number | Array<string | number>) => {
  return request({
    url: '/apartment/apartment/recover/' + id,
    method: 'put'
  });
};

/**
 * 永久删除公寓
 * @param id
 */
export const foreverDeleteApartment= (id: string | number | Array<string | number>) => {
  return request({
    url: '/apartment/apartment/foreverDelete/' + id,
    method: 'delete'
  });
};

/**
 * 状态修改
 * @param RoomForm 数据
 */
export function changeReleaseStatus(data: ApartmentForm) {
  return request({
    url: '/apartment/apartment/changeReleaseStatus',
    method: 'put',
    data: data
  });
}
